/**
 * 
 */
package kernel_gui.gui.extended;

import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;

import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Sequence;
import javax.sound.midi.Sequencer;

/**
 * @author Yoyo
 *
 */
public class EAboutForm extends kernel_gui.gui.generic.graphic.AboutForm {
	/**
	 * 
	 */
	private static final long serialVersionUID = -6347865524248595128L;
	
	private Sequencer sequencer = null;
	public EAboutForm() {
		
		//TODO - I'm opening a new thread for MIDI music - is it ok (Alona)?
		new Thread(new Runnable() {
			
			@Override
			public void run() {
				try {
			        // From file
			        Sequence sequence = MidiSystem.getSequence(new File("sound/WWTBAM.mid"));
			    
			        // Create a sequencer for the sequence
			        sequencer = MidiSystem.getSequencer();
			        sequencer.open();
			        sequencer.setSequence(sequence);
			        
			        sequencer.setTickPosition(27580);
			    
			        // Start playing
			        sequencer.start();
			    } catch (MalformedURLException e) {
			    } catch (IOException e) {
			    } catch (MidiUnavailableException e) {
			    } catch (InvalidMidiDataException e) {
			    }
				
			}
		}).start();

	}
	
	protected void BackButtonActionPerformed(ActionEvent evt) {
		if(sequencer != null)
			sequencer.stop();
		
		openAnotherFrame(EMainMenuFrame.class, true);
		
	}

	@Override
	protected void setWindowComponentsWhenCalledFromAnotherFrame() {
		/*not needed*/
	}


}
